{% extends "base.html" %}

{% block html_lang %}{{ article.lang }}{% endblock %}

{% block extra_head %}
  <meta name="author" content="{{ article.author }}">
  <meta name="keywords" content="{{ article.tags|join(',')|escape }}">
  <script src="/hashover-next/api/count-link.php"></script>
{% endblock %}

{% block head %}
{{ super() }}
{% import 'translations.html' as translations with context %}
{% if translations.entry_hreflang(article) %}
  {{ translations.entry_hreflang(article) }}
{% endif %}
<meta property="og:title" content="{{ article.title|striptags }}">
<meta property="og:type" content="article">
<meta property="og:url" content="{{ SITEURL }}/{{ article.url }}">
<meta property="article:published_time" content="{{ article.date.isoformat() }}">
{% if article.modified %}
  <meta property="article:modified_time" content="{{ article.modified.isoformat() }}">
{% endif %}
<meta property="article:section" content="{{ article.category }}">
{% set og_description = article.summary.split(ANOTHER_READ_MORE_LINK_FORMAT[:6])[0][3:]|striptags|escape %}
{% set OG_DESC_LENGTH = 175 %}
{% if og_description|length >= OG_DESC_LENGTH %}
    {# Quita la última palabra para no dejarla incompleta #}
    {% set og_description = og_description[:OG_DESC_LENGTH].split(' ')[:-1]|join(' ') %}
    {% if not og_description[-1] in ['.', '?', ':', '!'] %}
        {% set og_description = og_description + '…' %}
    {% endif %}
{% endif %}
<meta property="og:description" content="{{ og_description }}">
{% if article.image %}
  <meta property="og:image" content="{{ article.image.split('"')[1] }}">
{% endif %}
{% for tag in article.tags %}
  <meta property="og:tag" content="{{ tag | escape }}">
{% endfor %}
{% if article.styles %}
    {% for style in article.styles %}
        {{ style|format(SITEURL) }}
    {% endfor %}
{% endif %}
{% if article.js %}
    {% for script in article.js %}
        {% if 'top' in script[-7:] %}
            {{ script[:-5]|format(SITEURL) }}
        {% endif %}
    {% endfor %}
{% endif %}
{% if (article.next_article and article.next_article.image) or (article.prev_article and article.prev_article.image) %}
  <style>
    {% if article.next_article.image %}
        .post-navigation .nav-next { background-image: url({{ article.next_article.image.split('"')[1] if article.next_article.image }}); border-top: 0; }
        .post-navigation .nav-next .post-title, .post-navigation .nav-next a:hover .post-title, .post-navigation .nav-next .meta-nav { color: #fff; }
        .post-navigation .nav-next a:before { background-color: rgba(0, 0, 0, 0.4); }
    {% endif %}
    {% if article.prev_article.image %}
        .post-navigation .nav-previous { background-image: url({{ article.prev_article.image.split('"')[1] if article.prev_article.image }}); }
        .post-navigation .nav-previous .post-title, .post-navigation .nav-previous a:hover .post-title, .post-navigation .nav-previous .meta-nav { color: #fff; }
        .post-navigation .nav-previous a:before { background-color: rgba(0, 0, 0, 0.4); }
    {% endif %}
  </style>
{% endif %}
{% endblock %}

{% block title %}{{ article.title|striptags }}{% endblock %}

{% block content %}
  {% if article.image %}
    <article class="has-post-thumbnail post type-post status-publish format-standard hentry">
    <a class="post-thumbnail" href="{{ SITEURL }}/{{ article.url }}" aria-hidden="true">
      {{ article.image }}
    </a>
  {% else %}
    <article class="post type-post status-publish format-standard hentry">
  {% endif %}
  <header class="entry-header">
    <h1 class="entry-title" id="titulo">{{ article.title }}</h1>
  </header>

  <div class="entry-content">
    {{ article.content }}
  </div><!-- /.entry-content -->
  {% include 'article_info.html' %}
  </article>
  {% if article.prev_article or article.next_article %}
  <div class="navigation post-navigation" role="navigation">
    <h2 class="screen-reader-text">{{ _('Navegación de entradas') }} </h2>
    <div class="nav-links">
      {% if article.prev_article %}
      <div class="nav-previous">
        <a accesskey="A" href="{{ SITEURL }}/{{ article.prev_article.url }}" rel="prev">
          <span class="meta-nav" aria-hidden="true">{{ _('Anterior') }}</span>
          <span class="screen-reader-text">{{ _('Entrada anterior:') }}</span>
          <span class="post-title">{{ article.prev_article.title }}</span>
        </a>
      </div>
      {% endif %}
      {% if article.next_article %}
      <div class="nav-next">
        <a accesskey="S" href="{{ SITEURL }}/{{ article.next_article.url }}" rel="next">
          <span class="meta-nav" aria-hidden="true">{{ _('Siguiente') }}</span>
          <span class="screen-reader-text">{{ _('Entrada siguiente:') }}</span>
          <span class="post-title">{{ article.next_article.title }}</span>
        </a>
      </div>
      {% endif %}
    </div>
  </div>
  {% endif %}
  <div id="hashover" class="comments-area">
    <h2>{{ _('Comentarios') }}</h2>
    {% if DEFAULT_LANG == 'es' %}
      <script src="/hashover-next/comments.php"></script>
    {% else %}
      <script src="/hashover-next/loader.php"></script>
      <script>
      var hashover = new HashOver ('hashover', {
        settings: {
          language: '{{ HASHOVER_LANG }}',
        }
      });
      </script>
    {% endif %}
    <noscript>
      <p>{% trans trimmed abre_enlace='<a href="mailto:comentarios@freakspot.net?subject=Comentario_«%(titulo_art)s»">'|format(titulo_art=article.title|replace(' ', '%20')), cierra_enlace='</a>' %}
      Lo siento, el sistema de comentarios no funciona sin JavaScript. Si
      quieres, puedes {{ abre_enlace }}enviar tu comentario por correo
      electrónico{{ cierra_enlace }}. El comentario será publicado en el espacio
      reservado a comentarios de esta página.{% endtrans %}</p>
    </noscript>
  </div>
{% endblock %}
